package com.example.lj.uav.utils;

import com.example.lj.uav.bean.RouteLine;

import java.util.Calendar;
import java.util.Comparator;

public class TimeUtils implements Comparator<RouteLine> {

    @Override
    public int compare(RouteLine h1, RouteLine h2) {
        if (h1.getUpdateTime() > h2.getUpdateTime()) {
            return 1;
        } else if (h1.getUpdateTime() == h2.getUpdateTime()) {
            return 0;
        } else {
            return -1;
        }
    }

    public static String getDate() {
        Calendar cal = Calendar.getInstance();
        int y = cal.get(Calendar.YEAR);
        int m = cal.get(Calendar.MONTH);
        int d = cal.get(Calendar.DATE);
        int h = cal.get(Calendar.HOUR_OF_DAY);
        int mi = cal.get(Calendar.MINUTE);
        return (y + "-" + m + "-" + d + "-" + h + ":" + mi);
    }

}
